package cn.cjlmonster.demo02.ui;

import android.graphics.Color;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.leochuan.CenterSnapHelper;
import com.leochuan.GalleryLayoutManager;
import com.leochuan.PageSnapHelper;
import com.leochuan.ScaleLayoutManager;
import com.leochuan.ViewPagerLayoutManager;

import java.util.ArrayList;
import java.util.List;

import cn.cjlmonster.demo02.R;
import cn.cjlmonster.demo02.adapter.CardAdapter;
import cn.cjlmonster.demo02.base.BaseAppCompatActivity;
import cn.cjlmonster.demo02.decoration.GradientIndicatorDecoration;

/**
 * This project is Demo02
 * Created by cjl on 2021/11/9 10:27 下午.
 */

public class ViewPagerRVActivity extends BaseAppCompatActivity {

    @Override
    protected int getLayoutId() {
        return R.layout.activity_view_pager_rv;
    }

    @Override
    protected boolean canBack() {
        return true;
    }

    private List<Integer> mColors;
    private CardAdapter cardAdapter;

    @Override
    protected void initView() {
        RecyclerView recyclerView = findViewById(R.id.recyclerView);

//        GalleryLayoutManager layoutManager = new GalleryLayoutManager
//                .Builder(this, 50)
//                .build();
        ScaleLayoutManager layoutManager = new ScaleLayoutManager
                .Builder(this, 50)
                .setMoveSpeed(0.8f)
                .build();
        recyclerView.setLayoutManager(layoutManager);

        mColors = new ArrayList<>();
        mColors.add(Color.GREEN);
        mColors.add(Color.BLUE);
        mColors.add(Color.RED);
        
        new CenterSnapHelper().attachToRecyclerView(recyclerView);
//        new PageSnapHelper().attachToRecyclerView(recyclerView);

        cardAdapter = new CardAdapter(this, mColors);

        recyclerView.setAdapter(cardAdapter);

        recyclerView.addItemDecoration(new GradientIndicatorDecoration());
    }
}
